//
//  SPConversationViewController.m
//  Sport
//
//  Created by tikpen on 2018/4/29.
//  Copyright © 2018年 Cass. All rights reserved.
//

#import "SPConversationViewController.h"

@interface SPConversationViewController ()<EaseMessageViewControllerDataSource>
@property(nonatomic,strong)NSUserDefaults *userDefault;
@end

@implementation SPConversationViewController



-(id<IMessageModel>)messageViewController:(EaseMessageViewController *)viewController modelForMessage:(EMMessage *)message{
    NSLog(@"调用");
    id<IMessageModel>model = nil;
    model = [[EaseMessageModel alloc]initWithMessage:message];
    //为0代表对方发送 为1代表自己发送
    if ([message.from isEqualToString:[_userDefault objectForKey:@"phoneNumber"]]) {
        model.avatarURLPath = [_userDefault objectForKey:@"headimage"];
        model.nickname = [_userDefault objectForKey:@"nickname"];
    }
    else{
        model.avatarURLPath = _iconUrl;
        model.nickname = _nickname;
    }
    NSLog(@"messageId:%@",message.messageId);
    NSLog(@"messageconversationId:%@",message.conversationId);
    NSLog(@"messageFrom:%@",message.from);
    NSLog(@"messageTo:%@",message.to);
    return model;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    _userDefault = [NSUserDefaults standardUserDefaults];
    [self setDataSource:self];
    self.showRefreshFooter = YES;
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}



@end
